<template>
	<el-form label-width="130px" :model="form" :rules="rules" ref="queryForm" @submit.prevent>

		<el-row>
			<el-col :span="12">


				<el-form-item label="姓名" prop="name">
					<el-input v-model="form.name" style="width:180px;"></el-input>
				</el-form-item>

				<el-form-item label="编建单位名称" prop="staffingUnit">
					<el-input v-model="form.staffingUnit" style="width:180px;"></el-input>
				</el-form-item>

				<el-form-item label="性别" prop="sex">
					<el-input v-model="form.sex" style="width:180px;"></el-input>
				</el-form-item>

				<el-form-item label="职务" prop="duties">
					<el-input v-model="form.duties" style="width:180px;"></el-input>
				</el-form-item>



				<el-form-item label="证件类型" prop="type">
					<el-input v-model="form.type" style="width:180px;"></el-input>
				</el-form-item>

				<el-form-item label="证件号" prop="idNumber">
					<el-input v-model="form.idNumber" style="width:180px;"></el-input>
				</el-form-item>

				<el-form-item label="所属专业队" prop="proName">
					<el-select v-model="form.proName" size="default" placeholder="请选择" style="width: 180px" filterable>
						<el-option v-for="item in optionsB" :key="item.id" :label="item.typeB" :value="item.typeB"
							:disabled="props.editData?true:false" />
					</el-select>

				</el-form-item>

				<el-form-item label="专业队分队名" prop="teamId">
					<el-select v-model="form.teamId" size="default" placeholder="请选择" style="width: 180px" clearable
						filterable>
						<el-option v-for="item in options" :key="item.id" :label="item.typeX" :value="item.id" />
					</el-select>
				</el-form-item>


				<el-form-item label="所属编组名称" prop="peName">
					<el-input v-model="form.peName" style="width:180px;"></el-input>
				</el-form-item>

				<el-form-item label="是否专职" prop="isfulltime">
					<el-select v-model="form.isfulltime" size="default" placeholder="请选择" style="width: 180px"
						filterable>
						<el-option value="是" label="是" />
						<el-option value="否" label="否" />
					</el-select>
				</el-form-item>

				<el-form-item label="是否科研人员" prop="isscientific">
					<el-select v-model="form.isscientific" size="default" placeholder="请选择" style="width: 180px"
						filterable>
						<el-option value="是" label="是" />
						<el-option value="否" label="否" />
					</el-select>
				</el-form-item>

				<el-form-item label="是否专家" prop="isspecialist">
					<el-select v-model="form.isspecialist" size="default" placeholder="请选择" style="width: 180px"
						filterable>
						<el-option value="是" label="是" />
						<el-option value="否" label="否" />
					</el-select>
				</el-form-item>





			</el-col>

			<el-col :span="12">




				<el-form-item label="出生日期" prop="birthday">

					<el-date-picker v-model="form.birthday" type="date" size="default" format="YYYY-MM-DD"
						value-format="YYYY-MM-DD" style="width: 180px;" />
					<!-- <el-input v-model="form.birthday" style="width:180px;"
						@input="e => regOnlyNumSpot(e, form, 'ying', 0)"></el-input> -->
				</el-form-item>

				<el-form-item label="移动电话" prop="phone">
					<el-input v-model="form.phone" style="width:180px;"
						@input="e => regOnlyNumSpot(e, form, 'phone', 0)"></el-input>
				</el-form-item>

				<el-form-item label="办公电话" prop="office">
					<el-input v-model="form.office" style="width:180px;"
						@input="e => regOnlyNumSpot(e, form, 'office', 0)"></el-input>
				</el-form-item>

				<el-form-item label="家庭电话" prop="tel">
					<el-input v-model="form.tel" style="width:180px;"
						@input="e => regOnlyNumSpot(e, form, 'tel', 0)"></el-input>
				</el-form-item>

				<el-form-item label="电子邮件" prop="email">
					<el-input v-model="form.email" style="width:180px;"></el-input>
				</el-form-item>

				<el-form-item label="籍贯" prop="nation">
					<el-input v-model="form.nation" style="width:180px;"></el-input>
				</el-form-item>

				<el-form-item label="政治面貌" prop="politicsStatus">
					<el-input v-model="form.politicsStatus" style="width:180px;"></el-input>
				</el-form-item>




				<el-form-item label="是否服役" prop="isfuyi">
					<el-select v-model="form.isfuyi" size="default" placeholder="请选择" style="width: 180px" filterable>
						<el-option value="是" label="是" />
						<el-option value="否" label="否" />
					</el-select>
				</el-form-item>
				<el-form-item label="受训情况" prop="training">
					<el-select v-model="form.training" size="default" placeholder="请选择" style="width: 180px" filterable>
						<el-option value="已训" label="已训" />
						<el-option value="未训" label="未训" />
					</el-select>
				</el-form-item>
				<el-form-item label="是否专业对口" prop="isaboral">
					<el-select v-model="form.isaboral" size="default" placeholder="请选择" style="width: 180px" filterable>
						<el-option value="是" label="是" />
						<el-option value="否" label="否" />
					</el-select>
				</el-form-item>
				<el-form-item label="人员身份分类" prop="identityType">
					<el-select v-model="form.identityType" size="default" placeholder="请选择" style="width: 180px"
						filterable>
						<el-option value="军队" label="军队" />
						<el-option value="地方" label="地方" />
					</el-select>
				</el-form-item>

			</el-col>
		</el-row>


		<div style="display: flex;justify-content: flex-end;">
			<el-button @click="closethis()" @keyup.prevent @keydown.enter.prevent>取消</el-button>
			<el-button type="primary" @click="submit(queryForm)" @keyup.prevent @keydown.enter.prevent>确定</el-button>
		</div>

	</el-form>
</template>

<script setup>
	import {
		ref,
		reactive,
		onMounted
	} from 'vue'
	import {
		ElMessage
	} from 'element-plus'

	import {
		commonInterface
	} from '@/api/common/common'

	import {
		regOnlyNumSpot
	} from '@/utils/reg'

	import {
		commonZydTypeA,
		commonZydTypeB
	} from '@/api/common/common'



	const emit = defineEmits(['getList', 'closeWindow'])
	const props = defineProps(['editData', 'options', 'optionsB'])

	const form = ref({
		name: '',
		type: '战时编制'
	})

	const queryForm = ref('')

	const options = ref([])
	const optionsB = ref()
	const isShow = ref(true)

	//必填项
	const rules = reactive({
		name: [{
			required: true,
			message: "此选项不能为空!",
			trigger: "blur"
		}]

	})
	//取消
	const closethis = () => {
		emit('closeWindow')
	}

	//确定
	const submit = async (e) => {
		if (!e) return
		await e.validate((valid) => {
			if (valid) {
				let method = 'post'
				if (props.editData) method = 'put'
				commonInterface('/back/renfang/zhyd/staff/', form.value, method).then(result => {
					if (result.code === 200) {
						ElMessage.success(result.msg)
						emit('closeWindow')
						emit('getList')
					} else {
						ElMessage.error(result.msg)
					}
				})
			}
		})
	}

	onMounted(() => {
		options.value = props.options
		optionsB.value = props.optionsB
		if (props.editData) form.value = props.editData
	})
</script>

<style lang="scss" scoped>
</style>